/*
###################################################################
#
#		Name: 		smc_spraymanager.inc
#		Author:		Itsalati
#		Web:		http://www.soloistsmodcentral.com
#		Purpose:	Definitions for Spray Manager SQL and baninfo.
#		
###################################################################
*/

#if defined __smc_spraymanager_include
	#endinput	
#endif
#define __smc_spraymanager_include

#define MAX_QUERY_LENGTH 1024

#define MAX_AUTH_LENGTH 32
#define MAX_REASON_LENGTH 128

#define MAX_AUTH_ESCAPED (MAX_AUTH_LENGTH*2)+1
#define MAX_REASON_ESCAPED (MAX_REASON_LENGTH*2)+1
#define MAX_NAME_ESCAPED (MAX_NAME_LENGTH*2)+1

#define MAX_QUERY_QUEUE 128

#define CHECKQUERY_STORE 0
#define CHECKQUERY_REMOVE 1


enum QueryType
{
	QueryType_Invalid						= 0,
	QueryType_CheckExistsOnConnect 			= 1,
	QueryType_CheckExistsForStorage			= 2,
	QueryType_CheckExistsForRemoval			= 3,
	QueryType_Store 						= 4,
	QueryType_Remove						= 5,
	QueryType_Get							= 6,
	QueryType_GetMass						= 7
};

enum CSprayBanInfo 
{
	bool:bValid,
	String:auth[MAX_AUTH_ESCAPED],
	String:name[MAX_NAME_ESCAPED],
	String:adminauth[MAX_AUTH_ESCAPED],
	String:adminname[MAX_NAME_ESCAPED],
	String:reason[MAX_REASON_ESCAPED],
	expires
};
const csbiSize = _:CSprayBanInfo;	// Because the compiler likes to bitch about valid things.


enum CSprayQueryInfo
{
	m_nQueryUID,
	m_nAttemptCount,
	bool:m_bRunning,
	QueryType:m_qtype,
	Handle:m_hQueryData
};
const csqiSize = _:CSprayQueryInfo;


enum CSprayMenuPending
{
	m_bIsPending,
	m_nQueryIndex
};
const csmpSize = _:CSprayMenuPending;

/* Query cache contents
*
* CSprayQueryInfo:
* 	- bRunning
* 	- nAttemptCount
*	- qtQueryType
* 	- hQueryData (datapack)
*		- callingClient
* 		- banInfo
*/



/********************************************
* Formats an array into a CSprayBanInfo using the 
* supplied auth string and default values. Array length 
* must be equal to csbiSize
*
* @param 	auth 	Auth string to use in this baninfo.
* @param 	array 	The array to be formatted  
*/
stock BanInfo_GetNew( const String:sAuth[MAX_AUTH_LENGTH], CSprayBanInfo:dataStore[csbiSize] )
{
	strcopy( dataStore[auth], MAX_AUTH_LENGTH, sAuth );
	strcopy( dataStore[name], MAX_NAME_LENGTH, "<unknown>" );
	strcopy( dataStore[reason], MAX_REASON_LENGTH, "None" );
	strcopy( dataStore[adminauth], MAX_AUTH_LENGTH, "Console" );
	strcopy( dataStore[adminname], MAX_NAME_LENGTH, "Console" );
}

/********************************************
* Same as BanInfo_GetNew, but allows setting all values manually.
* Array length still must be equal to csbiSize.
*
* @param 	array 		The array to be formatted
* @param 	auth 		The auth string to insert
* @param 	name 		The name of the client
* @param 	reason 		The reason for the ban 
* @param 	adminauth 	The auth string of the admin
* @param 	adminnname 	The name of the admin
*/
stock BanInfo_GetNewEx( CSprayBanInfo:dataStore[csbiSize],\
	const String:sAuth[MAX_AUTH_LENGTH],\
	const String:sName[MAX_NAME_LENGTH],\
	const String:sReason[MAX_REASON_LENGTH],\
	const iExpires,\
	const String:sAdminAuth[MAX_AUTH_LENGTH],\
	const String:sAdminName[MAX_NAME_LENGTH] )
{
	strcopy( dataStore[auth], 		MAX_AUTH_LENGTH, 	sAuth );
	strcopy( dataStore[name], 		MAX_NAME_LENGTH,	sName );
	strcopy( dataStore[reason],		MAX_REASON_LENGTH, 	sReason );
	strcopy( dataStore[adminauth], 	MAX_AUTH_LENGTH, 	sAdminAuth );
	strcopy( dataStore[adminname], 	MAX_NAME_LENGTH, 	sAdminName );

	dataStore[expires] = iExpires;
}
